<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>教练换科目</title>
    <link href="<%=path%>/CSS/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .scbtn {
            background: #57a0ff;
            border-radius: 20px;
            width: 110px;
            height: 35px;
        }

        .seachform li label {
            line-height: 35px;
            color: #444444
        }

        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .tablelist {
            border: none;
            margin: 10px 20px
        }

        .tablelist th {
            background: none;
            border-bottom: none;
        }

        thead {
            background: #f2f2f2
        }

        /*tbody tr:nth-child(even) {
            background: #f7f8fd
        }*/

        .tablelist th {
            height: 45px;
        }

        .tablelist td {
            border-right: none;
        }

        tbody tr {
            height: 38px
        }

        .check {
            padding-left: 0px
        }

        a {
            cursor: pointer;
        }

        #student td {
            width: 100%;
            padding-left: 30px;
            text-align: center;
        }

        .head th {
            text-align: center;
        }

        #cent td {
            text-align: center;
            padding-left: 5px;
        }

        table tr td {
            font-size: 12px
        }

        table tr th {
            font-size: 14px
        }

        .heads span {
            width: 1573px;
            float: left;
            height: 45px;
            text-align: center;
            line-height: 45px;
            background: #eee;
            font-weight: bold;
            font-size: 14px;
        }

        .wrap {
            width: 190px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .checkName {
            width: 72px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .createName {
            width: 72px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .stust {
            width: 62px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .tablelist tr td {
            text-align: center;
        }

        .tablelist tr {
            border-bottom: #cccccc 1px solid;
        }

        .tablelist tr th {
            text-align: center;
        }

        .solid_ccc {
            border-left: #cccccc 1px solid;
        }
    </style>
</head>
<body style="background: #f5f5f5;padding: 0 10px;">
<div id="location_top">
<div class="place" style="background: #f5f5f5;margin-top: 10px">
    <ul class="placeul">
        <li><a href="#">教练管理</a></li>
        <li><a href="<%=path%>/DrivingSys/queryCoachSub/look.action?state=first">教练换科目</a></li>
    </ul>
</div>
<%--提示的隐藏标识--%>
<input type="hidden" id="alertType" value="${alertType}">
<div class="rightinfo" style="padding-top: 20px;background: #fff;border-radius:10px;height: 45px;">

    <form action="<%=path%>/DrivingSys/queryCoachSub/look.action" method="post">
        <ul class="seachform">
            <li><label>教练</label><input name="jlName" type="text" class="scinput"
                                        value="${jlName}"/></li>
            <li><label>教练编码</label><input name="cfcoachno" type="text" class="scinput"
                                          value="${cfcoachno}"/></li>
            <li><label>开始时间</label><input class="scinput1" name="beginTime" type="text"
                                          onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd'})"
                                          id="datemin" class="input-text Wdate" style="width:150px;"
                                          value="${beginTime}"></li>
            <li><label>结束时间</label><input class="scinput1" name="endTime" type="text"
                                          onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',dateFmt:'yyyy-MM-dd'})"
                                          id="datemax" class="input-text Wdate" style="width:150px;" value="${endTime}">
            </li>
            <li><label>&nbsp;</label><input name="" type="submit" style="outline: none;" class="scbtn" value="立即查询"/>
            </li>
        </ul>
    </form>
</div>
</div>
<div id="data_table_new"
     style="margin-bottom: 0px;margin-top: 30px;background: #fff;border-radius:10px;box-shadow: 0 0 10px #f2f2f2;">
    <ul>
        <li style="height: 40px;text-align: left;color: #999999;">
				  <span style="font-size: 12px;">
                      <shiro:hasPermission name="/go_add_Coachsub">
                          <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                               src="<%=path%>/images/list/xz.png">
                          &nbsp;<a onclick="gotoSelectCard(this)" funurl="<%=path%>/DrivingSys/go_add_Coachsub">新增</a>
                      </shiro:hasPermission>
                      <shiro:hasPermission name="/delete_Coachsub">
                          <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                               src="<%=path%>/images/list/sc.png">
                          &nbsp;<a class="del">删除</a>
                      </shiro:hasPermission>
                      <shiro:hasPermission name="/go_update_Coachsub">
                          <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                               src="<%=path%>/images/list/xg.png" style="padding-left: 20px">
                          <a style="color: #000" class="modify">修改</a>
                      </shiro:hasPermission>
                      <shiro:hasPermission name="/queryCoachSubXls">
                             <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                                  src="<%=path%>/images/list/excel.png" style="padding-left: 20px">
                          <a style="color: #000" id="importExcel">导出Excle</a>
                      </shiro:hasPermission>
				  </span>
        </li>
    </ul>
    <table class="tablelist" id="table1" style="white-space:nowrap;">
        <thead>
        <tr>
            <th class="sq"><input type="checkbox" class="check1"></th>
            <th>单据编号</th>
            <th>业务日期</th>
            <th>参考消息</th>
            <th>审核人名称</th>
            <th>制单人名称</th>
            <th>单据状态</th>
            <th>教练</th>
            <th>教练编码</th>
            <th>原教学科目</th>
            <th>原来车型</th>
            <th>备注</th>
            <th>现在学科目</th>
            <th>现在车型</th>
            <th>操作</th>
        </tr>
        </thead>
        <c:forEach items="${coachsubList}" var="coachsubList" varStatus="s">
            <tr class="sharecarsub">
                <td><input type="checkbox" name="check" <c:if test="${coachsubList.cfbillstate != 3}"> disabled="disabled" </c:if> value="${coachsubList.fid}"/></td>
                <td>${coachsubList.fnumber}</td>
                <td>${coachsubList.fbizdate}</td>
                <td>${coachsubList.fdescription}</td>
                <td>${coachsubList.checkName}</td>
                <td>${coachsubList.createName}</td>
                <c:if test="${coachsubList.cfbillstate eq 3}">
                    <td class="state">保存</td>
                </c:if>
                <c:if test="${coachsubList.cfbillstate eq 4}">
                    <td class="state">提交</td>
                </c:if>
                <c:if test="${coachsubList.cfbillstate eq 5}">
                    <td class="state">审核</td>
                </c:if>
                <td class="solid_ccc">${coachsubList.jlName}</td>
                <td>${coachsubList.cfjiaolianno}</td>
                <c:if test="${coachsubList.cfdqsub eq 1}">
                    <td>科目一</td>
                </c:if>
                <c:if test="${coachsubList.cfdqsub eq 2}">
                    <td>科目二</td>
                </c:if>
                <c:if test="${coachsubList.cfdqsub eq 3}">
                    <td>科目三</td>
                </c:if>
                <td>${coachsubList.cfdqcartype}</td>
                <td>${coachsubList.cfdesc}</td>
                <c:if test="${coachsubList.cfxzsub eq 1}">
                    <td>科目一</td>
                </c:if>
                <c:if test="${coachsubList.cfxzsub eq 2}">
                    <td>科目二</td>
                </c:if>
                <c:if test="${coachsubList.cfxzsub eq 3}">
                    <td>科目三</td>
                </c:if>
                <td>${coachsubList.cfxzcartype}</td>
                <td>
                    <shiro:hasPermission name="/go_update_Coachsub">
                        <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                             src="<%=path%>/images/list/xg.png">
                        <a href="<%=path%>/DrivingSys/go_update_Coachsub?fid=${coachsubList.fid}"
                           class="tablelink">修改</a>&nbsp;&nbsp;&nbsp;
                    </shiro:hasPermission>
                    <shiro:hasPermission name="/delete_Coachsub">
                        &nbsp;&nbsp;&nbsp;<img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;" src="<%=path%>/images/list/sc.png">
                        <a class="delOne" class="tablelink" style="color: #056dae">删除
                            <input type="hidden" value="${coachsubList.fid}">
                            <input type="hidden" value="${coachsubList.fnumber}"></a>
                    </shiro:hasPermission>
                </td>
            </tr>
        </c:forEach>
        <%--合计信息总条数--%>
        <tr class="sq">
            <td>合计:</td>
            <td>${messageAmount}</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
</div>
<div id="location_bottom">
<pg:pager items="${pb.tr}" url="${pb.url}" export="offset,currentPageNumber=pageNumber"
          maxPageItems="${pb.ps}">
    <pg:param name="fnumber" value="${fnumber}"/>
    <pg:param name="cfcoachno" value="${cfcoachno}"/>
    <pg:param name="jlName" value="${jlName}"/>
    <pg:param name="beginTime" value="${beginTime}"/>
    <pg:param name="endTime" value="${endTime}"/>
    <pg:index>
        <pg:first>
            <a href="${pageUrl}&&type=${type}">
                <nobr>
                    [首页]
                </nobr>
            </a>
        </pg:first>
        <pg:prev><a href="${pageUrl}&&type=${type}">前一页</a></pg:prev>
        <pg:pages>
            <c:choose>
                <c:when test="${currentPageNumber eq pageNumber}">
                    <font color="red">${pageNumber }</font>
                </c:when>
                <c:otherwise>
                    <a href="${pageUrl}&&type=${type}">${pageNumber}</a>
                </c:otherwise>
            </c:choose>
        </pg:pages>
        <pg:next><a href="${pageUrl}&&type=${type}">下一页</a></pg:next>
        <pg:last><a href="${pageUrl}&&type=${type}">
            <nobr>[尾页]</nobr>
        </a></pg:last>
    </pg:index>
</pg:pager>
</div>
<div class="tip">
    <div class="tiptop">
        <span>提示信息</span>
    </div>
    <div class="tipinfo">
        <span><img src="<%=path%>/images/ticon.png"/></span>
        <div class="tipright">
            <p>是否确认对信息删除 ？</p>
            <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
    </div>
    <div class="tipbtn">
        <input name="" type="button" class="sure" value="确定"/>&nbsp; <input
            name="" type="button" class="cancel" value="取消"/>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JS/tempJs/tool.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        fixation_List()
        _w_table_rowspan("#table1", "1")
        _w_table_rowspan("#table1", "2")
        _w_table_rowspan("#table1", "3")
        _w_table_rowspan("#table1", "4")
        _w_table_rowspan("#table1", "5")
        _w_table_rowspan("#table1", "6")
        _w_table_rowspan("#table1", "7")
        _w_table_rowspan("#table1", "15")


        function _w_table_rowspan(_w_table_id, _w_table_colnum) {
            _w_table_firsttd = "";
            _w_table_currenttd = "";
            _w_table_SpanNum = 0;
            _w_table_Obj = $(_w_table_id + ' tr td:nth-child(' + _w_table_colnum + ')');
            _w_table_Obj.each(function (i) {
                if (i == 0) {
                    _w_table_firsttd = $(this);
                    _w_table_SpanNum = 1;
                    _td = $(this).parent().find('td:eq(1)');
                }
                else {
                    _w_table_currenttd = $(this);
                    _td2 = $(this).parent().find('td:eq(1)');
                    if (_td.text() == _td2.text()) {
                        _w_table_SpanNum++;
                        _w_table_currenttd.hide(); //remove();
                        _w_table_firsttd.attr("rowSpan", _w_table_SpanNum);
                    } else {
                        _w_table_firsttd = $(this);
                        _td = $(this).parent().find('td:eq(1)');
                        _w_table_SpanNum = 1;
                    }
                }
            });
        }

        //删除多个
        $('.del').click(function () {
            var sq = $("input[name='check']").is(":checked");
            if (sq == false) {
                alert("请至少选择一条数据删除")
            } else {
                $(".tip").fadeIn(200);
            }
            $(".sure").unbind("click").click(function () {
                var str = new Array();
                var fnumber = new Array();
                var s = '0';
                $("input[name='check']:checked").each(function (i) {
                    var state = $(this).parent().parent().find(".state").text();
                    if (state == "提交" || state == "审核") {
                        s = '1';
                        return false
                    } else {
                        str[i] = $(this).val();
                        fnumber[i] = $(this).parent().next().text();
                    }
                })
                if (s == '1') {
                    alert("提交或审核状态不能被删除")
                    $(".tip").fadeOut(100);
                } else {
                    location = '<%=path%>/DrivingSys/delete_Coachsub?deleteId=' + str + '&fnumber='+fnumber;
                }
            })

            $(".cancel").click(function () {
                $(".tip").fadeOut(100);
            });
        })
        //删除单个
        $('.delOne').click(function () {
            var fid = $(this).find("input:hidden").val();
            var fnumber = $(this).find("input:hidden").next().val();
            var state2 = $(this).parent().parent().find(".state").text();
            if (state2 == "提交" || state2 == "审核") {
                alert("提交或审核状态不能被删除")
                $(".tip").fadeOut(200);
            } else {
                $('.window-mask').fadeToggle()
                $(".tip").fadeIn(200);
                $(".sure").unbind("click").click(function () {
                    $('.window-mask').fadeOut()
                    location = '<%=path%>/DrivingSys/delete_Coachsub?deleteId=' + fid + '&fnumber='+fnumber;
                })
            }

            $(".cancel").click(function () {
                $(".tip").fadeOut(100);
            });
        })

        //修改
        $(".modify").click(function () {
            var stringFid;
            var fids = document.getElementsByName("check");
            for (var i = 0; i < fids.length; i++) {
                if (fids[i].checked) {
                    stringFid = fids[i].value;
                    location = '<%=path%>/DrivingSys/go_update_Coachsub?fid=' + stringFid + '';
                    return false
                }
            }
            if (stringFid == null || stringFid.length == 0) {
                alert("请至少选择一条数据修改")
                return false
            }
        })

        //查询详情
        $(".tablelist tr:gt(0)").dblclick(function () {
            var modify = $(".modify").text();
            if (modify == '' || modify == null) {

            } else {
                var fid2 = $(this).find("input[name=check]").val();
                //避免fid中有+，或者特殊字符
                var fid = encodeURI(fid2).replace(/\+/g, '%2B')
                gotoSelectCard(this,'/DrivingSys/go_update_Coachsub?fid='+fid);

                //location = '<%=path%>/DrivingSys/go_update_Coachsub?fid=' + fid + '';
            }
        })
        //全选全不选
        $(".check1").click(function () {
            if (this.checked) {
                $("[name=check]").not(':disabled').attr("checked", true);
            }
            else {
                $("[name=check]").attr("checked", false);
            }
        })

        $("#importExcel").click(function () {
            var jlName = $("input[name='jlName']").val();
            var cfcoachno = $("input[name='cfcoachno']").val();
            var beginTime = $("input[name='beginTime']").val();
            var endTime = $("input[name='endTime']").val();

            location = '<%=path%>/DrivingSys/queryCoachSubXls?jlName='
                + jlName + '&cfcoachno=' + cfcoachno + '&beginTime='
                + beginTime + '&endTime=' + endTime;
        })
    })
</script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
</html>